package com.adtech.adms.order;

import java.util.List;

import com.adtech.adms.device.pojo.GuiOrder;
import com.adtech.adms.system.SystemConstants;
import com.adtech.adms.system.pojo.User;
import com.adtech.core.dao.HibernateDAO;
import com.adtech.core.dao.exp.Expression;
import com.adtech.core.dao.query.Pager;
import com.adtech.core.dao.query.QueryConstants;
import com.adtech.core.dao.query.Sort;
import com.adtech.core.exception.ServiceException;

public class OrderServiceImpl implements OrderService {
	private HibernateDAO dao;

	@Override
	public void save(GuiOrder order) throws ServiceException {
		dao.add(order);
	}
	public void setDao(HibernateDAO dao) {
		this.dao = dao;
	}
	@Override
	public List<GuiOrder> getOrderList(Pager pager, Expression expression,
			Sort sort) {
		if(sort==null || sort.isEmpty()) {
			sort = new Sort();
			sort.addSort(SystemConstants.Order.IMPORT_DATE, QueryConstants.DESC);
		}
		return (List<GuiOrder>)dao.getByQuery(GuiOrder.class, pager, expression, sort);
	}
}
